package com.example.chongwushangcheng.enums;

/**
 * 商品拍卖状态枚举
 *
 * @author 芋道源码
 */
public enum ProductAuctionStatusEnum {

    READY(0, "待开始"),
    STARTING(1, "进行中"),
    END(2, "已结束"),
    REJECT(3, "已撤销");

    /**
     * 状态值
     */
    private final Integer status;
    
    /**
     * 状态名
     */
    private final String name;

    ProductAuctionStatusEnum(Integer status, String name) {
        this.status = status;
        this.name = name;
    }

    public Integer getStatus() {
        return status;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据状态值获取枚举
     */
    public static ProductAuctionStatusEnum getByStatus(Integer status) {
        if (status == null) {
            return null;
        }
        for (ProductAuctionStatusEnum statusEnum : values()) {
            if (statusEnum.getStatus().equals(status)) {
                return statusEnum;
            }
        }
        return null;
    }

    /**
     * 获取所有状态值数组
     */
    public static Integer[] getAllStatusArray() {
        ProductAuctionStatusEnum[] values = values();
        Integer[] array = new Integer[values.length];
        for (int i = 0; i < values.length; i++) {
            array[i] = values[i].getStatus();
        }
        return array;
    }
} 